@isTest
private class testOptySolutionControllerExtension
{
 static testMethod void testOpportunitySolutionExtensionController()
  {

  // Inserted an opportunity for a solution to be associated to it later   
    Opportunity  opty1 = new Opportunity();
    opty1.Name='TestOpty1';
    opty1.CloseDate=system.today();
    opty1.StageName='Prospecting';
    opty1.Amount=10002;
    opty1.Contract_Term__c = 0;
    opty1.TCV_HRO__c = 200;
    //opty1.TCV_Technology__c = 100;
    //opty1.TCV_Outsourcing__c = 100;
    insert opty1;
    
    List<Schema.RecordTypeInfo> recinfo1 = Account.SObjectType.getDescribe().getRecordTypeInfos();
    List<ID> recType1 = new List<ID>();
    For(integer i=0;i<recinfo1.size() ;i++)
    {
     recType1.add(recinfo1[i].getRecordTypeID());
     system.debug('+++++ record type account name ' + recinfo1[i].getName());
    }
    //Inserted an Account for a solution to be associated to it later
    Account acc=new Account();
    acc.name='account1';
    acc.Type='Prospect';
    acc.industry='Aerospace & Defense';
    acc.NumberOfEmployees=100;
    acc.CurrencyIsoCode='EUR';
    acc.Region__c='North America';
    acc.Phone='9773090872'; 
    acc.BillingCity='NaviMumbai';
    acc.BillingCountry='India';
    insert acc;   
   // fetch the record types available for solution Object 
    List<Schema.RecordTypeInfo> recinfo = Solution__C.SObjectType.getDescribe().getRecordTypeInfos();
    List<ID> recType = new List<ID>();
    For(integer i=0;i<recinfo.size() ;i++)
    {
     recType.add(recinfo[i].getRecordTypeID());
     system.debug('+++++ record type name ' + recinfo[i].getName());
    }
   
         
        Solution__c solcon = new Solution__c();
       solcon.Opportunity__c = opty1.id;  
       solcon.opportunity__r = opty1;
       solcon.Product__c = 'Upgrade';  // to test the validation rule 'Requiredfield'
       solcon.recordtypeID = recType[0];//inserted the 'consulting' recordtype
       
       Solution__c solout = new Solution__c();
       solout.Account__c=acc.id;
       //solout.Opportunity__c = opty1.id;  
      // solout.opportunity__r = opty1;       
       solout.Deployment__c = 'Managed';
       solout.Product__c = 'HR Outsourcing';  // to test the validation rule 'Requiredfield'
       solout.recordtypeID = recType[1];//inserted the 'Outsourcing' recordtype
       
       Solution__c solsoft = new Solution__c();
       solsoft.Opportunity__c = opty1.id;  
       solsoft.opportunity__r = opty1;
       solsoft.Deployment__c = 'Provisioning';
       solsoft.Product__c = 'Optimum';  // to test the validation rule 'Requiredfield'
       solsoft.recordtypeID = recType[2];//inserted the 'Software' recordtype
       
        
      // insert solcon; 
      // insert solout;
       insert solsoft;      
    
   //Passed the solution created to OpportunitySolutionExtensionController  constructor
    
   OpportunitySolutionExtensionController myExt1 = new  OpportunitySolutionExtensionController(new ApexPages.standardController(solcon));
   OpportunitySolutionExtensionController myExt2 = new  OpportunitySolutionExtensionController(new ApexPages.standardController(solout));
 OpportunitySolutionExtensionController myExt3 = new  OpportunitySolutionExtensionController(new ApexPages.standardController(solsoft));
    
    
  myExt1.initialise();  
  myExt1.BeforeNew();
  SolutionComponent__c sc=new  SolutionComponent__c();
  sc.Name='Develop';     
  sc.Component__c='AL-Albania';
  myExt1.components.add(sc);
  myExt1.copySectionItem();
  myExt1.save();
  myExt1.cancel();
  myExt1.compIdx = 'sssssssssss';
  myExt1.toDelete = sc.id;  
  myExt1.deleteSectionItem();  
   
   
   myExt2.initialise();  
  myExt2.BeforeNew();
  SolutionComponent__c sc1=new  SolutionComponent__c();
  sc1.Name='Develop';     
  sc1.Component__c='AL-Albania';
  myExt2.components.add(sc1);   
  myExt2.save();  
  myExt2.cancel();
  myExt2.compIdx = 'sssssssssss';
  myExt2.toDelete = sc1.id;  
  myExt2.deleteSectionItem();     
 
   
    myExt3.initialise();  
  myExt3.BeforeNew();
  SolutionComponent__c sc2=new  SolutionComponent__c();
  sc2.Name='Develop';     
  sc2.Component__c='AL-Albania';
  myExt3.components.add(sc2);  
  myExt3.copySectionItem();
  myExt3.save();  
  myExt3.cancel();
  myExt3.compIdx = 'sssssssssss';
  myExt3.copySectionItem();
  myExt3.toDelete = sc2.id;  
  myExt3.deleteSectionItem(); 
   
   
         
  
  } 
  
}